#ifndef PRAXIS_SERVICES_TRIGGER_ENGINE_H_
#define PRAXIS_SERVICES_TRIGGER_ENGINE_H_

#include <praxis/core/backend_stubs.h>

#include <memory>

namespace praxis {
/**
 * @class CTriggerEngine
 * @brief Evaluates rules against machine state and logs events.
 *
 * This service observes the machine state, compares it against a set of
 * predefined rules (triggers), and logs an event to a CSV file whenever
 * a trigger's state changes (e.g., from 'released' to 'triggered').
 */
class PRAXIS_API CTriggerEngine {
 public:
  /**
   * @brief Constructs the engine.
   * @param trigger_definitions The JSON array containing all trigger rules.
   */
  explicit CTriggerEngine(const json& trigger_definitions);
  ~CTriggerEngine();

  CTriggerEngine(const CTriggerEngine&) = delete;
  CTriggerEngine& operator=(const CTriggerEngine&) = delete;

  /**
   * @brief Evaluates all rules against the provided machine state.
   *
   * This method is the core of the engine and should be called on every
   * machine state update.
   * @param current_machine_state The latest state from the MachineSimulator.
   */
  void Evaluate(const json& current_machine_state);

 private:
  struct Impl;
  std::unique_ptr<Impl> impl_;
};
}  // namespace praxis

#endif  // PRAXIS_SERVICES_TRIGGER_ENGINE_H_
